package com.westa.smallshop.shop;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.westa.smallshop.R;
import com.westa.smallshop.common.BaseActivity;
import com.westa.smallshop.data.source.remote.GoodsItemRemoteDataSource;
import com.westa.smallshop.user.UserInfoActivity;
import com.westa.smallshop.util.ActivityUtils;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by cy123 on 2016/9/13.
 */
public class ShopActivity extends BaseActivity {

    public static void startActivity(Activity activity) {

        Intent intent = new Intent(activity, ShopActivity.class);
        activity.startActivity(intent);

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop);
        ButterKnife.bind(this);

        setCenterToolbarTitle(true);
        setHasNavigationIcon(false);
        ShopFragment shopFragment = (ShopFragment) getSupportFragmentManager()
                .findFragmentById(R.id.fragment_layout);

        if (shopFragment == null) {
            shopFragment = ShopFragment.newInstance();
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(),
                    shopFragment, R.id.fragment_layout);

        }

        new ShopPresenter(shopFragment, new GoodsItemRemoteDataSource(getApplicationContext()));
    }


    @OnClick(R.id.iv_user_portrait)
    public void onClick() {
        UserInfoActivity.startActivity(this);
    }
}
